#ifndef WIDGET_H
#define WIDGET_H

#include "workproces.h"
#include <QDebug>
#include <QDir>
#include <QFileDialog>
#include <QFileInfo>
#include <QFileInfoList>
#include <QFileSystemWatcher>
#include <QMessageBox>
#include <QProcess>
#include <QStandardPaths>
#include <QThreadPool>
#include <QTimer>
#include <QWidget>

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget {
  Q_OBJECT

public:
  Widget(QWidget *parent = nullptr);
  ~Widget();

public:
  void onReadData(const QByteArray &);
  void onReadError(const QByteArray &);
  void runnableFinished();
private slots:
  void on_selectDexPath_clicked();
  void deleteDirectory(const QString &path);
  QStringList getDirectoryFileList(const QString &path,
                                   const QStringList &filters);
  void on_jdkBtn_clicked();

  void on_dexBrowerBtn_clicked();

  void on_dex2SmliBtn_clicked();

  void directoryChanged(const QString &);
  void fileChanged(const QString &path);
  void upDexFileList();
  void on_jdkEdit_editingFinished();

  void on_dexPath_editingFinished();

  void on_dexOutEdit_editingFinished();

  void findBackSmali();

signals:
  void setProcInfo(const QString &objName, const QString &jdk,
                   const QString &cmd, const QStringList &list);
  void doWork();

private:
  bool isDirExist(QString fullPath);

private:
  Ui::Widget *ui;
  QString savePath;
  QString dexPath;
  QString smaliPath;
  QString jdkPath;
  QProcess procCov;
  QList<workProces *> workPool;
  QList<QStringList> poolListParam;
  int fileCount, finishedCount;
  QFileSystemWatcher *dexPathWatch;
  QStringList bakSmaliList;
  QStringList smaliList;
};
#endif // WIDGET_H
